Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ce_config: Optimize multi-level views & fix a bug. #59523

Merged
merged 6 commits into from
Jul 29, 2019
Merged

ce_config: Optimize multi-level views & fix a bug. #59523

merged 6 commits into from
Jul 29, 2019

Conversation

yuandongx
Copy link
Contributor

@yuandongx yuandongx commented Jul 24, 2019

SUMMARY

Optimize multi-level views

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/modules/network/cloudengine/ce_config.py

ADDITIONAL INFORMATION

test case

  - name: "Step2.1.1 Loading command configuration from lines"
    ce_config:
      lines: 
        - interface vlanif 3111
        - description test_vlanif3111_1
        - interface vlanif 3112
        - description test_vlanif3112_1
      match: none

error log

atal: [10.190.121.125]: FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "invocation": {
        "module_args": {
            "after": null,
            "backup": false,
            "backup_options": null,
            "before": null,
            "config": null,
            "defaults": false,
            "host": "10.190.121.125",
            "lines": [
                "interface vlanif 3111",
                "description test_vlanif3111_1",
                "interface vlanif 3112",
                "description test_vlanif3112_1"
            ],
            "match": "none",
            "parents": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "port": 10111,
            "provider": {
                "host": "10.190.121.125",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "port": 10111,
                "ssh_keyfile": null,
                "timeout": null,
                "transport": "cli",
                "use_ssl": null,
                "username": "huawei",
                "validate_certs": null
            },
            "replace": "line",
            "save": false,
            "src": null,
            "ssh_keyfile": null,
            "timeout": null,
            "transport": "cli",
            "use_ssl": null,
            "username": "huawei",
            "validate_certs": null
        }
    },
    "msg": "Command: interface vlanif 3112, error[1]: unrecognized command found."
}

PLAY RECAP **************************************************************************
10.190.121.125             : ok=0    changed=0    unreachable=0    failed=1    skippe                                                                            d=0    rescued=0    ignored=0

debug result

Module does not support multi-view jumps.
An error happened when commands try to change contexts.

after fixed, test log

changed: [10.190.121.125] => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "commands": [
        "interface vlanif 3111",
        "description test_vlanif3111_1",
        "interface vlanif 3112",
        "description test_vlanif3112_1"
    ],
    "invocation": {
        "module_args": {
            "after": null,
            "backup": false,
            "backup_options": null,
            "before": null,
            "config": null,
            "defaults": false,
            "host": null,
            "lines": [
                "interface vlanif 3111",
                "description test_vlanif3111_1",
                "interface vlanif 3112",
                "description test_vlanif3112_1"
            ],
            "match": "none",
            "parents": null,
            "password": null,
            "port": null,
            "provider": {
                "host": "10.190.121.125",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "port": 10111,
                "ssh_keyfile": null,
                "timeout": null,
                "transport": "cli",
                "use_ssl": null,
                "username": "huawei",
                "validate_certs": null
            },
            "replace": "line",
            "save": false,
            "src": null,
            "ssh_keyfile": null,
            "timeout": null,
            "transport": "cli",
            "use_ssl": null,
            "username": null,
            "validate_certs": null
        }
    },
    "updates": [
        "interface vlanif 3111",
        "description test_vlanif3111_1",
        "interface vlanif 3112",
        "description test_vlanif3112_1"
    ]
}
META: ran handlers
META: ran handlers

PLAY RECAP ************************************************************************************
10.190.121.125             : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

show configure on device.


[~8850_130.12]di cu | section in Vlanif311
#
interface Vlanif3111
 description test_vlanif3111_1
 ospf enable 1 area 0.0.0.1
#
interface Vlanif3112
 description test_vlanif3112_1
[~8850_130.12]

@ansibot
Copy link
Contributor

ansibot commented Jul 24, 2019

@ansibot ansibot added WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. networking Network category owner_pr This PR is made by the module's maintainer. support:community This issue/PR relates to code supported by the Ansible community. labels Jul 24, 2019
@ansibot
Copy link
Contributor

ansibot commented Jul 24, 2019

@yuandongx yuandongx marked this pull request as ready for review July 29, 2019 06:29
@ansibot
Copy link
Contributor

ansibot commented Jul 29, 2019

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

lib/ansible/modules/network/cloudengine/ce_config.py:352:19: undefined-variable Undefined variable 'ignore_line'
lib/ansible/modules/network/cloudengine/ce_config.py:380:19: undefined-variable Undefined variable 'ignore_line'

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/network/cloudengine/ce_config.py:223:0: ImportError: cannot import name _NetworkConfig

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/network/cloudengine/ce_config.py:223:0: ImportError: cannot import name _NetworkConfig

The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/network/cloudengine/ce_config.py:223:0: ImportError: cannot import name '_NetworkConfig'

The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/network/cloudengine/ce_config.py:223:0: ImportError: cannot import name '_NetworkConfig'

The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/network/cloudengine/ce_config.py:223:0: ImportError: cannot import name '_NetworkConfig' from 'ansible.module_utils.network.common.config' (/root/ansible/test/runner/.tox/import/lib/ansible/module_utils/network/common/config.py)

The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:

lib/ansible/modules/network/cloudengine/ce_config.py:223:0: ImportError: cannot import name '_NetworkConfig' from 'ansible.module_utils.network.common.config' (/root/ansible/test/runner/.tox/import/lib/ansible/module_utils/network/common/config.py)

The test ansible-test sanity --test validate-modules [explain] failed with 4 errors:

lib/ansible/modules/network/cloudengine/ce_config.py:0:0: E321 Exception attempting to import module for argument_spec introspection, 'cannot import name '_NetworkConfig''
test/sanity/ignore.txt:2720:1: A100 Ignoring 'E322' on 'lib/ansible/modules/network/cloudengine/ce_config.py' is unnecessary
test/sanity/ignore.txt:2721:1: A100 Ignoring 'E337' on 'lib/ansible/modules/network/cloudengine/ce_config.py' is unnecessary
test/sanity/ignore.txt:2722:1: A100 Ignoring 'E338' on 'lib/ansible/modules/network/cloudengine/ce_config.py' is unnecessary

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Jul 29, 2019
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jul 29, 2019
@yuandongx yuandongx changed the title WIP ce_config: Optimize multi-level views & fix a bug. ce_config: Optimize multi-level views & fix a bug. Jul 29, 2019
@yuandongxx
Copy link
Contributor

shipit

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. automerge This PR was automatically merged by ansibot. shipit This PR is ready to be merged by Core and removed WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. community_review In order to be merged, this PR must follow the community review workflow. needs_triage Needs a first human triage before being processed. labels Jul 29, 2019
@ansibot ansibot merged commit 9182d54 into ansible:devel Jul 29, 2019
abadger pushed a commit that referenced this pull request Jul 30, 2019
…#59523) (#59728)

* ce_config: Optimize multi-level views & fix a bug. (#59523)

* Optimize multi-level views

* update to rewrite load_config.

* update.

* update.

* update.

* update.

(cherry picked from commit 9182d54)

* add a changelog fragment.
@ansible ansible locked and limited conversation to collaborators Aug 26, 2019
@yuandongx yuandongx deleted the bug/ce_config/20190724 branch September 16, 2019 09:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 automerge This PR was automatically merged by ansibot. bug This issue/PR relates to a bug. module This issue/PR relates to a module. networking Network category owner_pr This PR is made by the module's maintainer. shipit This PR is ready to be merged by Core support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants